package Com.javaserver.servlet;

import Com.javaserver.bean.admid;
import Com.javaserver.bean.rewland;
import Com.javaserver.bean.salary;
import Com.javaserver.bean.staff;
import Com.javaserver.dao.addmiserver;
import Com.javaserver.dao.staffserver;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/admidele")
public class admideleserverlet  extends HttpServlet {
   addmiserver a=new addmiserver();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String dele=req.getParameter("dele");
        admid s=new admid();
        s.setId(Integer.parseInt(dele));

        if (a.admidele(s) == false){
            req.getSession().setAttribute("msg", "删除失败");
            resp.sendRedirect(req.getContextPath() + "/system.jsp");
        }else {
            List<admid> list = a.admi(1);
            req.getSession().setAttribute("admi", list);
            req.getSession().setAttribute("msg", "删除成功");
            resp.sendRedirect(req.getContextPath() + "/admi");
        }

    }
}
